package com.six.flower.controller

import com.six.library.utils.Constant
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cloud.client.loadbalancer.LoadBalanced
import org.springframework.context.annotation.Bean
import org.springframework.web.bind.annotation.*
import org.springframework.web.client.RestTemplate


/*-*- coding:utf-8 -*-
 * @Author  : debi
 * @Time    : 10/24/22
 * @Software: IntelliJ IDEA
 */
@RestController
@RequestMapping("/nacos")
@CrossOrigin
class NacosController {
    @LoadBalanced
    @Bean
    fun restTemplate(): RestTemplate {
        return RestTemplate()
    }

    @RestController
    class TestController @Autowired constructor(private val restTemplate: RestTemplate) {
        @RequestMapping(value = ["/OK"], method = [RequestMethod.GET])
        fun echo(@PathVariable str: String): String {
            return restTemplate.getForObject(Constant.EpidemicReport + "/echo/$str", String::class.java) as String
        }
    }
}